package com.mobzilla.activity;



import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class NameListActivity extends Activity
{
	private static String title;
	private static String[] names;
	
	public static void setParam(String ttl, String[] nms)
	{
		title = ttl;
		names = nms;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);		
		setContentView(R.layout.namelist);
		
		TextView ttl = (TextView) findViewById(R.id.title);
		ttl.setText(title);
		
		if(names.length==0)
		{
			Toast.makeText(this, "No user names available.", Toast.LENGTH_LONG).show();
		}
		else
		{
			TextView name = null;
			for(int i=0; i<5 && i<names.length; i++)
			{
				switch (i)
				{
				case 0: name = (TextView) findViewById(R.id.name1);
						break;
				case 1: name = (TextView) findViewById(R.id.name2);
						break;
				case 2: name = (TextView) findViewById(R.id.name3);
						break;
				case 3: name = (TextView) findViewById(R.id.name4);
						break;
				case 4: name = (TextView) findViewById(R.id.name5);
						break;				
				}			
				name.setText(names[i]);
			}
		}		

		Button backButton = (Button) findViewById(R.id.nameBackButton);		
		backButton.setOnClickListener(new BackButtonListener(this));
	}


}
